﻿<?php
class Product_Service_ReceivingItem
{
	public static $statusText = array(
		"0" => "未收货",
		"1" => "收货中",
		"2" => "已收货",
		"3" => "QC完成",
	);


	public function __construct(){
		
	}
	
	public function add($row){
		$Obj = new Product_Model_ReceivingItem();
		return $Obj->add($row);		
	}
		
	public function delete($value,$field){
		$Obj = new Product_Model_ReceivingItem();
		return $Obj->delete($value,$field);		
	}
	
	public static function updateAsnPid($row,$cond)
	{ 
		if($cond['product_id']=='' || $cond['receiving_code']==''){
			return false;
		}
		$obj=new Product_Model_ReceivingItem();
		return $obj->updateAsnPid($row,$cond);
	}
	
	public static function getByCondition($condition=array(),$type='*',$page="", $pageSize="")
	{ 
		$obj=new Product_Model_ReceivingItem();
		$rows= $obj->getByCondition($condition,$type, $page,$pageSize);	
		if(is_array($rows)){
			foreach($rows as $key=>$row){
				$rows[$key]["statusText"] = self::$statusText[$row['status']];
			}
		}
		return $rows;
	}
	
	public static function getByReceivingId($id)
	{ 
		$obj=new Product_Model_ReceivingItem();
		$rows=$obj->getByReceivingId($id);
		if(!empty($rows)){
			$rows=$rows->toArray();
		}
		return $rows;
	}
	
	public static function getByReceivingAsnPid($cond)
	{ 
		if($cond['product_id']=='' || $cond['receiving_code']==''){
			return false;
		}
		$obj=new Product_Model_ReceivingItem();
		$rows=$obj->getByReceivingAsnPid($cond);
		if(!empty($rows)){
			$rows=$rows->toArray();
		}
		return $rows;
	}
	
	/**
	 * 根据指定字段返回一行数据
	 * 
	 **/
	public function getRowByValue($value,$field){
		$Obj = new Product_Model_ReceivingItem();
		return $Obj->getRowByValue($value,$field);	
	}
	
	/**
	 * 根据指定字段返回多行数据
	 *
	 * @param $value 相应字段值
	 * @param $field 字段名称
	 * @return 
	 */
	public static function getAllByValue($value,$field){
		$Obj = new Product_Model_ReceivingItem();
		return $Obj->getAllByValue($value,$field);	
	}

}